% GAUTIER LE BIHAN - 2020
% Replication files for "Shocks vs Menu Costs: Patterns of Price Rigidity in an Estimated Multi-Sector 
% Menu-Cost Model" Review of Economics and Statistics
%
% This code produces  Appendix figure E from simulated moments 

cd ..\..\Simu_identification\simu_univ_MC
load stat_outsample_19.mat 

stat_outsampleb=stat_outsample_19(:,1:end)

%% The first 4 columns are the parameters
params_vec=stat_outsampleb(:, 2:3)   ;
%% The first folllowing columns are the moments
moments_vec=stat_outsampleb(:, 5:end)  ;


%%% Reminder:
%%% Order is    params_vec(ss,:) = [p0 mu_c sig_c sig_eps_a];

disp( '%%%%%%%%%%%%%%%%    Parameters value for the baseline case   %%%%%%%%%%%%%%%%%%%%%%%%%%');

rho_base =0.694600000000000;
p0_base = 0.0;
mu_c_base =[0.00633521405560053];
sig_eps_a_base = exp(-3.93088893868755);


%% Note when  sig_eps_a ==0 , then the relation between moments and mu_c is well behaved (average_dp increasing function of mu_c
%%% Interpretation : when mu_c is large price changes are mainly trigerred by the inflation trend




 figure(1);
param_plot = 1;
%%% Vector of mu_c, holding other parameters to their default values
%aa = abs(params_vec(:,1)- p0_base);
%aa_min = min(aa);
% bb = abs(params_vec(:,3)-sig_c_base );
% bb_min = min(bb);
cc = abs(params_vec(:,2)-sig_eps_a_base );
cc_min = min(cc);
%dd = abs(params_vec(:,4)-rho_base );
%dd_min = min(dd);
plot_vec = (cc==cc_min);%&(dd==dd_min);


subplot(2,5,1)
hold on;
plot(params_vec(plot_vec~=0,param_plot),moments_vec(plot_vec~=0,1), '-b');
plot([mu_c_base mu_c_base],[0 0.2], '--r');
axis([min(params_vec(:,1)) 0.0074 0 0.20])
xlabel('\mu') % x-axis label
ylabel('Freq. Changes') % y-axis label
hold off;

subplot(2,5,2)
hold on;
plot(params_vec(plot_vec~=0,param_plot),moments_vec(plot_vec~=0,2), '-b');
plot([mu_c_base mu_c_base],[0.5 0.8], '--r');
axis([min(params_vec(:,1)) 0.0074 0.5 0.8])
xlabel('\mu') % x-axis label
ylabel('Share of increases') % y-axis label
hold off;

subplot(2,5,3)
hold on;
plot(params_vec(plot_vec~=0,param_plot),moments_vec(plot_vec~=0,3), '-b');
plot([mu_c_base mu_c_base],[0 0.08], '--r');
axis([min(params_vec(:,1)) 0.0074  0.0 0.08])
xlabel('\mu') % x-axis label
ylabel('Median') % y-axis label
hold off;

subplot(2,5,4)
hold on;
plot(params_vec(plot_vec~=0,param_plot),moments_vec(plot_vec~=0,4), '-b');
plot([mu_c_base mu_c_base],[0 0.15], '--r');
axis([min(params_vec(:,1)) 0.0074  0.0 0.15])
xlabel('\mu') % x-axis label
ylabel('Interquartile') % y-axis label
hold off;

subplot(2,5,5)
hold on;
plot(params_vec(plot_vec~=0,param_plot),moments_vec(plot_vec~=0,5), '-b');
plot([mu_c_base mu_c_base],[0 4], '--r');
axis([min(params_vec(:,1)) 0.0074  0 4])
xlabel('\mu') % x-axis label
ylabel('Kurtosis') % y-axis label
hold off;


%figure(2);
param_plot = 2;
%%% Vector of mu_c, holding other parameters to their default values
aa = abs(params_vec(:,1)- mu_c_base);
aa_min = min(aa);
% bb = abs(params_vec(:,3)-sig_c_base );
% bb_min = min(bb);
%cc = abs(params_vec(:,2)-mu_c_base );
%cc_min = min(cc);
%dd = abs(params_vec(:,4)-rho_base );
%dd_min = min(dd);
plot_vec = (aa==aa_min);


subplot(2,5,6)
hold on;
plot(params_vec(plot_vec~=0,param_plot),moments_vec(plot_vec~=0,1), '-b');
plot([sig_eps_a_base sig_eps_a_base],[0 0.2], '--r');
axis([min(params_vec(:,2)) 0.022  0. 0.2])
xlabel('\sigma') % x-axis label
ylabel('Freq. changes') % y-axis label
hold off;

subplot(2,5,7)
hold on;
plot(params_vec(plot_vec~=0,param_plot),moments_vec(plot_vec~=0,2), '-b');
plot([sig_eps_a_base sig_eps_a_base],[0.5 0.8], '--r');
axis([min(params_vec(:,2)) 0.022  0.5 0.8])
xlabel('\sigma') % x-axis label
ylabel('Share of increases') % y-axis label
hold off;

subplot(2,5,8)
hold on;
plot(params_vec(plot_vec~=0,param_plot),moments_vec(plot_vec~=0,3), '-b');
plot([sig_eps_a_base sig_eps_a_base],[0 0.08], '--r');
axis([min(params_vec(:,2)) 0.022  0 0.08])
xlabel('\sigma') % x-axis label
ylabel('Median') % y-axis label
hold off

subplot(2,5,9)
hold on;
plot(params_vec(plot_vec~=0,param_plot),moments_vec(plot_vec~=0,4), '-b');
plot([sig_eps_a_base sig_eps_a_base],[0.0 0.15], '--r');
axis([min(params_vec(:,2)) 0.022  0.0 0.15])
xlabel('\sigma') % x-axis label
ylabel('Interquartile') % y-axis label
hold off;

subplot(2,5,10)
hold on;
plot(params_vec(plot_vec~=0,param_plot),moments_vec(plot_vec~=0,5), '-b');
plot([sig_eps_a_base sig_eps_a_base],[0 4], '--r');
axis([min(params_vec(:,2)) 0.022  0 4])
xlabel('\sigma') % x-axis label
ylabel('Kurtosis') % y-axis label
hold off;


%print('..\figures\identu_MC.pdf','-dpdf', '-fillpage')

